package com.wbcs.config.template.tags;

import com.wbcs.system.ReportRequest;
import com.wbcs.system.assistant.TagAssistant;
import com.wbcs.system.component.AbsComponentType;
import com.wbcs.system.component.container.AbsContainerType;
import com.wbcs.util.Consts;
import com.wbcs.util.Consts_Private;

public class SButtonTag extends AbsTagInTemplate
{
    public SButtonTag(AbsTagInTemplate parentTag)
    {
        super(parentTag);
    }

    @Override
	public String getTagname()
    {
        return Consts_Private.TAGNAME_BUTTON;
    }

    @Override
	public String getDisplayValue(ReportRequest rrequest,AbsComponentType ownerComponentObj)
    {
        if(this.tagContent==null) this.tagContent="";
        mTagAttributes.put("label",tagContent);
        String type=this.mTagAttributes.get("type");
        AbsComponentType displayComponentObj=null;
        if(Consts.lstDataExportTypes.contains(type))
        {
            String componentid=this.mTagAttributes.get("componentid");
            this.mTagAttributes.put("componentids",componentid);
            displayComponentObj=ownerComponentObj;
        }else
        {
            displayComponentObj=this.getDisplayComponentObj(rrequest);
            if(displayComponentObj==null) displayComponentObj=ownerComponentObj;
        }
        if(!(displayComponentObj instanceof AbsContainerType))
        {
            return TagAssistant.getInstance().getButtonDisplayValue(displayComponentObj,mTagAttributes);
        }else
        {
            return TagAssistant.getInstance().getButtonDisplayValueForContainer((AbsContainerType)displayComponentObj,mTagAttributes);
        }
    }
}
